

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <style type="text/css">

    </style>
    <title>年历</title>
    <style>
        .yueli{
            border:1px solid blue;
        }
        .data{
            display: grid;
            padding: 8px;
            grid-template-columns: repeat(7,auto);
        }
        .nianli{
            border: 3px solid red;
            display: grid;
            gap: 10px;
            padding: 10px;
            grid-template-columns: repeat(6,auto);
        }
        .yue{
            text-align: center;
            color: red;
            font-weight: bold;
            line-height: 2;
        }
        .data>div{
            text-align: center;
        }
        .title{
            color: red;
            font-size: 32px;
            font-weight: bold;
            text-align: center;
            line-height: 2;
        }
        select{
            width: 160px;
            padding: 8px;
        }

    </style>
</head>
<body><?php
$d=new DateTime();
$currentYear=$d->format('Y');
$year=$_GET["year"]??$currentYear;

?>
<script>
    function nav(value){
        console.log(value)
        location.href='?year='+value
    }
</script>
<div class='kuang'>
    <select onchange="nav(value)">
        <?php
        for ($i=$currentYear;$i>$currentYear-10;--$i){
            echo "<option",$i==$year?" selected":""," value='$i'>$i </option>";
        }
        ?>

    </select>
    <div class="title"><?=$year?></div>
    <div class='nianli'>
        <?php
        for ($month=1;$month<=12;$month++){
            echo "<div class='yueli'>";
            echo "<div class='yue'>{$month}月</div>";
            echo "<div class='data'>";
            echo "<div>一</div><div>二</div><div>三</div><div>四</div><div>五</div><div>六</div><div>日</div>";
            $d=new DateTime("$year-$month-1");
            $space= $d->format('N')-1;
            echo str_repeat("<div></div>",$space);
            $days= $d->format('t');
            for ($i=1;$i<=$days;$i++){
                echo "<div>{$i}</div>";
            }
            echo "</div></div>";
        }
        ?>
    </div>
</div>
</body>
</html>


